package gov.mogaha.ntis.cmm.mob;

import java.io.Serializable;

/**<B><I>public class Address implements {@link Serializable}</B></I><BR>
 * 액티비티 간 주소를 전달할 때 사용할 수 있는 클래스.<P>
 * setAddressType()메소드를 사용해 주소 형식을 지번주소 형식인지 새주소 형식인지를 지정하지 않으면 
 * <U>기본값으로 지번주소가 주소형식으로 지정</U>된다.
 * @author 이전봉
 * @version 1.3
 */
public class Address implements Serializable {
	private static final long serialVersionUID = 3L;
	
	/** 주소형식 - 지번주소 형식
	 * @see <LI><B>setAddressType(int type)</B></LI>
	 */
	private final static  int TYPE_JIBUN = 0xF00001;
	
	/** 주소형식 - 새주소 형식
	 * @see <LI><B>setAddressType(int type)</B></LI>
	 */
	private static final int TYPE_NEW = 0xF00002;
	
	/** 현재 주소형식을 나타내는 변수. 기본값으로 지번주소를 갖는다.
	 * @see <LI>{@link Address}<B> - setAddressType(int type)</B></LI>
	 * @see <LI>{@link Address}<B> - getAddressType()</B></LI>
	 */
	private int addressType = TYPE_JIBUN;
	
	/**<B><I>public void setAddressType(int type)</B></I><BR>
	 * Address 개체의 주소 형식을 지정한다.<P>
	 * Address개체의 static변수로 
	 * <B>TYPE_JIBUN</B>와 <B>TYPE_NEW</B>를 사용할 수 있다. 
	 * 기본값으로 TYPE_JIBUN값을 가지며, 
	 * 지정된 값 이외의 값은 기본값으로 처리한다.
	 * @param type 주소형식
	 * @see <LI><B>{@link Address.TYPE_JIBUN TYPE_JIBUN}</B></LI>
	 * @see <LI><B>{@link Address.TYPE_NEW TYPE_NEW}</B></LI>
	 */
	public void setAddressType(int type) {
		switch (type) {
		case TYPE_JIBUN: case TYPE_NEW:
			this.addressType = type;
			this.addressType = type;
			break;
		default :
			this.addressType = TYPE_JIBUN;
		}
	}
	
	/**<B><I>public int getAddressType() </B></I><BR>
	 * Address개체의 주소 형식을 구한다.
	 * @return 주소형식
	 */
	public int getAddressType() {
		return addressType;
	}
	
	
	
	/**<B><I>public static String parseAddress({@link Address Address} address)</B></I><BR>
	 * Address 주소 객체의 주소값을 주소검색 화면의 '주소' 입력창에 들어가는 형식의 문자열로 바꿔준다.<BR>
	 * 예를 들어, <P>
	 * <PRE>
	 * 대전광역시 대덕구 대화동 산128-8　　>　　대전광역시 대덕구 대화동
	 * 대전광역시 대덕구 평촌동 128-28　　>　　대전광역시 대덕구 평촌동</PRE>
	 * @param address {@link Address Address} 주소 객체
	 * @return <LI>변환된 형식의 주소 문자열</LI>
	 */
	public static String parseAddress(Address address) {
		StringBuilder builder = new StringBuilder();
		
		try {
			switch (address.getAddressType()) {
			case Address.TYPE_JIBUN :
				try {
					String[] datas = address.getaddrOverall().split(" ");
					boolean indexed = false;
					
					for (String data : datas) {
						if (data.matches("산[0-9]*.*")
								|| data.matches("[0-9]*")
								|| data.matches("[0-9]*-[0-9]*")) break;
						else if (!indexed) builder.append(data);
						else if (indexed) builder.append(" "+data);
						indexed = true;
					}
				} catch (Exception e) {
					return "";
				}
				break;
				
			case Address.TYPE_NEW :
				break;
				
			default :
				break;
			}
			
		} catch (Exception e) {
			return "";
		}
		
		return builder.toString();
	}
	
	
	
	protected String	admdngCode;
	
	private String	addrOverall;
	private String	addrIsSan;
	private String	addrSan;
	private String	addrBunji;
	private String	addrHo;
	private String	addrTong;
	private String	addrBan;
	private String	addrDetailAddr;
	private String	addrDetailDong;
	private String	addrDetailHo;
	
	protected String	isSrchJibun;
	private String	addrSiGunGu;
	private String	addrRoadname;
	private String	addrBldNum1;
	private String	addrBldNum2;
	private String	addrIsUnder;
	private String	addrBldName1;
	private String	addrBldName2;
	private String	addrBldDong;
	private String	addrBldFloor;
	private String	addrBldHo;
	
	protected String	riNm;
	protected String	sidoNm;
	protected String	cggNm;
	protected String	admdngNm;
	protected String	umdNm;
	protected String	regnCode;
	protected String	rdnSidoNm;
	protected String	rdnCggNm;
	protected String	rdnCggCode;
	protected String	rdnCode;
	protected String	rdnNm;
	protected String	rdnUmdCode;
	protected String	rdnUmdGbn;
	protected String	rdnUmdNm;
    protected String	rdnUmdNo;
	
    
    
    public Address() {
    	admdngCode = "";
    	
    	addrOverall = "";
    	addrIsSan = "";
    	addrSan = "";
    	addrBunji = "";
    	addrHo = "";
    	addrTong = "";
    	addrBan = "";
    	addrDetailAddr = "";
    	addrDetailDong = "";
    	addrDetailHo = "";
    	
    	isSrchJibun = "";
    	addrSiGunGu = "";
    	addrRoadname = "";
    	addrBldNum1 = "";
    	addrBldNum2 = "";
    	addrIsUnder = "";
    	addrBldName1 = "";
    	addrBldName2 = "";
    	addrBldDong = "";
    	addrBldFloor = "";
    	addrBldHo = "";
    	
    	riNm = "";
    	sidoNm = "";
    	cggNm = "";
    	admdngNm = "";
    	umdNm = "";
    	regnCode = "";
    	rdnSidoNm = "";
    	rdnCggNm = "";
    	rdnCggCode = "";
        rdnCode = "";
        rdnNm = "";
        rdnUmdCode = "";
        rdnUmdGbn = "";
        rdnUmdNm = "";
        rdnUmdNo = "";
	}
    
    
    
    public String getAdmdng_code() {
		return admdngCode;
	}

	public void setAdmdng_code(String admdngCode) {
		this.admdngCode = admdngCode;
	}

	public String getRi_nm() {
		return riNm;
	}

	public void setRi_nm(String riNm) {
		this.riNm = riNm;
	}

	public String getSido_nm() {
		return sidoNm;
	}

	public void setSido_nm(String sidoNm) {
		this.sidoNm = sidoNm;
	}

	public String getCgg_nm() {
		return cggNm;
	}

	public void setCgg_nm(String cggNm) {
		this.cggNm = cggNm;
	}

	public String getAdmdng_nm() {
		return admdngNm;
	}

	public void setAdmdng_nm(String admdngNm) {
		this.admdngNm = admdngNm;
	}

	public String getUmd_nm() {
		return umdNm;
	}

	public void setUmd_nm(String umdNm) {
		this.umdNm = umdNm;
	}

	public String getaddrIsUnder() {
		return addrIsUnder;
	}

    public String getAdmdng_Code() {
    	return admdngCode;
    }
    
	public String getaddrOverall() {
		return addrOverall;
	}

	public String isaddrIsSan() {
		return addrIsSan;
	}
	
	public String getaddrSan() {
		return addrSan;
	}

	public String getaddrBunji() {
		return addrBunji;
	}

	public String getaddrHo() {
		return addrHo;
	}

	public String getaddrTong() {
		return addrTong;
	}

	public String getaddrBan() {
		return addrBan;
	}

	public String getaddrDetailAddr() {
		return addrDetailAddr;
	}

	public String getaddrDetailDong() {
		return addrDetailDong;
	}

	public String getaddrDetailHo() {
		return addrDetailHo;
	}

	public void setaddrOverall(String aDDR_Overall) {
		addrOverall = aDDR_Overall;
	}

	public void setaddrIsSan(String aDDR_IsSan) {
		addrIsSan = aDDR_IsSan;
	}
	
	public void setaddrSan(String aDDR_San) {
		addrSan = aDDR_San;
	}

	public void setaddrBunji(String aDDR_Bunji) {
		addrBunji = aDDR_Bunji;
	}


	public void setaddrHo(String aDDR_Ho) {
		addrHo = aDDR_Ho;
	}


	public void setaddrTong(String aDDR_Tong) {
		addrTong = aDDR_Tong;
	}

	public void setaddrBan(String aDDR_Ban) {
		addrBan = aDDR_Ban;
	}

	public void setaddrDetailAddr(String aDDR_DetailAddr) {
		addrDetailAddr = aDDR_DetailAddr;
	}

	public void setaddrDetailDong(String aDDR_DetailDong) {
		addrDetailDong = aDDR_DetailDong;
	}


	public void setaddrDetailHo(String aDDR_DetailHo) {
		addrDetailHo = aDDR_DetailHo;
	}

	public String getIs_srch_jibun() {
		return isSrchJibun;
	}
	public void setIs_srch_jibun(String isSrchJibun) {
		this.isSrchJibun = isSrchJibun;
	}
    public String getRegn_code() {
		return regnCode;
	}
	public void setRegn_code(String regnCode) {
		this.regnCode = regnCode;
	}
	public String getRdn_sido_nm() {
		return rdnSidoNm;
	}
	public void setRdn_sido_nm(String rdnSidoNm) {
		this.rdnSidoNm = rdnSidoNm;
	}
	public String getRdn_cgg_nm() {
		return rdnCggNm;
	}
	public void setRdn_cgg_nm(String rdnCggNm) {
		this.rdnCggNm = rdnCggNm;
	}
	
    
    public String getRdn_cgg_code() {
		return rdnCggCode;
	}
	public void setRdn_cgg_code(String rdnCggCode) {
		this.rdnCggCode = rdnCggCode;
	}
	public String getRdn_code() {
		return rdnCode;
	}
	public void setRdn_code(String rdnCode) {
		this.rdnCode = rdnCode;
	}
	public String getRdn_nm() {
		return rdnNm;
	}
	public void setRdn_nm(String rdnNm) {
		this.rdnNm = rdnNm;
	}
	public String getRdn_umd_code() {
		return rdnUmdCode;
	}
	public void setRdn_umd_code(String rdnUmdCode) {
		this.rdnUmdCode = rdnUmdCode;
	}
	public String getRdn_umd_gbn() {
		return rdnUmdGbn;
	}
	public void setRdn_umd_gbn(String rdnUmdGbn) {
		this.rdnUmdGbn = rdnUmdGbn;
	}
	public String getRdn_umd_nm() {
		return rdnUmdNm;
	}
	public void setRdn_umd_nm(String rdnUmdNm) {
		this.rdnUmdNm = rdnUmdNm;
	}
	public String getRdn_umd_no() {
		return rdnUmdNo;
	}
	public void setRdn_umd_no(String rdnUmdNo) {
		this.rdnUmdNo = rdnUmdNo;
	}
	

	

	
	public String getaddrSiGunGu() {
		return addrSiGunGu;
	}
	public String getaddrRoadname() {
		return addrRoadname;
	}
	public String getaddrBldNum1() {
		return addrBldNum1;
	}
	public String getaddrBldNum2() {
		return addrBldNum2;
	}
	public String isaddrIsUnder() {
		return addrIsUnder;
	}
	public String getaddrBldName1() {
		return addrBldName1;
	}
	public String getaddrBldName2() {
		return addrBldName2;
	}
	public String getaddrBldDong() {
		return addrBldDong;
	}
	public String getaddrBldFloor() {
		return addrBldFloor;
	}
	public String getaddrBldHo() {
		return addrBldHo;
	}
	
	public void setaddrSiGunGu(String aDDR_SiGunGu) {
		addrSiGunGu = aDDR_SiGunGu;
	}
	public void setaddrRoadname(String aDDR_Roadname) {
		addrRoadname = aDDR_Roadname;
	}
	public void setaddrBldNum1(String aDDR_BldNum1) {
		addrBldNum1 = aDDR_BldNum1;
	}
	public void setaddrBldNum2(String aDDR_BldNum2) {
		addrBldNum2 = aDDR_BldNum2;
	}
	public void setaddrIsUnder(String aDDR_IsUnder) {
		addrIsUnder = aDDR_IsUnder;
	}
	public void setaddrBldName1(String aDDR_BldName1) {
		addrBldName1 = aDDR_BldName1;
	}
	public void setaddrBldName2(String aDDR_BldName2) {
		addrBldName2 = aDDR_BldName2;
	}
	public void setaddrBldDong(String aDDR_BldDong) {
		addrBldDong = aDDR_BldDong;
	}
	public void setaddrBldFloor(String aDDR_BldFloor) {
		addrBldFloor = aDDR_BldFloor;
	}
	public void setaddrBldHo(String aDDR_BldHo) {
		addrBldHo = aDDR_BldHo;
	}

	@Override
	public String toString() {
		return "Address [addrBan=" + addrBan + ", addrBldDong="
				+ addrBldDong + ", addrBldFloor=" + addrBldFloor
				+ ", addrBldHo=" + addrBldHo + ", addrBldName1="
				+ addrBldName1 + ", addrBldName2=" + addrBldName2
				+ ", addrBldNum1=" + addrBldNum1 + ", addrBldNum2="
				+ addrBldNum2 + ", addrBunji=" + addrBunji
				+ ", addrDetailAddr=" + addrDetailAddr + ", addrDetailDong="
				+ addrDetailDong + ", addrDetailHo=" + addrDetailHo
				+ ", addrHo=" + addrHo + ", addrIsSan=" + addrIsSan
				+ ", addrIsUnder=" + addrIsUnder + ", addrOverall="
				+ addrOverall + ", addrRoadname=" + addrRoadname
				+ ", addrSiGunGu=" + addrSiGunGu + ", addrTong=" + addrTong
				+ ", Address_Type=" + addressType + ", admdng_code="
				+ admdngCode + ", admdng_nm=" + admdngNm + ", cgg_nm="
				+ cggNm + ", is_srch_jibun=" + isSrchJibun
				+ ", rdn_cgg_code=" + rdnCggCode + ", rdn_cgg_nm="
				+ rdnCggNm + ", rdn_code=" + rdnCode + ", rdn_nm=" + rdnNm
				+ ", rdn_sido_nm=" + rdnSidoNm + ", rdn_umd_code="
				+ rdnUmdCode + ", rdn_umd_gbn=" + rdnUmdGbn
				+ ", rdn_umd_nm=" + rdnUmdNm + ", rdn_umd_no=" + rdnUmdNo
				+ ", regn_code=" + regnCode + ", ri_nm=" + riNm
				+ ", sido_nm=" + sidoNm + ", umd_nm=" + umdNm + "]";
	}
}

























